package test.ui {
	import gear.core.Game;
	import gear.net.LibData;
	import gear.net.RESManager;
	import gear.net.SWFLoader;
	import gear.ui.cell.LabelSource;
	import gear.ui.controls.GList;
	import gear.ui.controls.GSpinner;
	import gear.ui.core.GAlign;
	import gear.ui.data.GListData;
	import gear.ui.data.GSpinnerData;

	import flash.events.Event;

	/**
	 * @version 20091215
	 * @author bright
	 */
	[SWF(width=1000,height=570,backgroundColor=0x333333,frameRate=30)]
	public class TestGSpinner extends Game {
		protected var _spinner : GSpinner;
		protected var _list : GList;

		override protected function startup() : void {
			RESManager.instance.add(new SWFLoader(new LibData("assets/ui.swf")));
			RESManager.instance.addEventListener(Event.COMPLETE, completeHandler);
			RESManager.instance.load();
		}

		private function completeHandler(event : Event) : void {
			addSpinner();
			addList();
			initView();
		}

		private function addSpinner() : void {
			var data : GSpinnerData = new GSpinnerData();
			data.x = 10;
			data.y = 10;
			data.parent = this;
			_spinner = new GSpinner(data);
			addChild(_spinner);
		}

		private function addList() : void {
			var data : GListData = new GListData();
			data.x = 100;
			data.y = 10;
			data.width = 200;
			data.padding = 3;
			data.cellData.width = 100;
			data.cellData.height = 22;
			data.align = new GAlign(0, -1, -1, 23, -1, -1);
			data.parent = this;
			_list = new GList(data);
			addChild(_list);
		}

		private function initView() : void {
			_spinner.model = _list.model;
			_spinner.selectionModel.index = 0;
			_list.model.source = [new LabelSource("test1"), new LabelSource("test2")];
		}

		public function TestGSpinner() {
			super();
		}
	}
}
